<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<svg width="400" height="400">
    <rect id="target" x="10" y="10" width="80" height="80">
    </rect>
</svg>
<script>
'use strict';

// From UseCounter.h
var SVGSMILAnimationAppliedEffect = 1477;

var testHandle = async_test("Count when SMIL animation has been applied");

requestAnimationFrame(function() {
    requestAnimationFrame(function() {
        testHandle.step(function() {
            var animation = document.createElementNS("http://www.w3.org/2000/svg", "animate");
            animation.setAttribute("attributeType", "XML");
            animation.setAttribute("attributeName", "y");
            animation.setAttribute("from", "210");
            animation.setAttribute("to", "310");
            animation.setAttribute("begin", "-5");
            animation.setAttribute("dur", "20");
            target.appendChild(animation);
            assert_false(internals.isUseCounted(document, SVGSMILAnimationAppliedEffect));
        });

        requestAnimationFrame(function() {
            requestAnimationFrame(function() {
                testHandle.step(function() {
                    assert_true(internals.isUseCounted(document, SVGSMILAnimationAppliedEffect));
                    testHandle.done();
                });
            });
        });
    });
});

</script>
